﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Handrise.CDCable.Mobile.Business;
using System.IO;
using HandRise.MBHOP.Controls;

namespace Handrise.CDCable.Mobile.UI
{
    public partial class FrmEditRecord : FrmBase
    {
        private LinkFile linkFile;

        private LinkFileService linkFileService = new LinkFileService();

        public FrmEditRecord()
        {
            InitializeComponent();

            ttlbrhead.Text = "录音标题修改";
            ilstbcup.Images.Add(ResourceImage.保存01);
            ilstbcup.Images.Add(ResourceImage.键盘01);
            ilstbcup.Images.Add(ResourceImage.返回01);
            ilstdown.Images.Add(ResourceImage.保存02);
            ilstdown.Images.Add(ResourceImage.键盘02);
            ilstdown.Images.Add(ResourceImage.返回02);
        }

        private void FrmEditRecord_Load(object sender, EventArgs e)
        {
            if (IsReturn)
                LoadCacheData();
            else
                LoadData();

            tbTitle.Text = linkFile.Title;

            if (File.Exists(linkFile.FullFileName))
            {
                FileInfo fileInfo = new FileInfo(linkFile.FullFileName);
                lblDateTime.Text = fileInfo.CreationTime.ToString("yyyy年MM月dd日");
                lblFileSize.Text = (fileInfo.Length / 1024).ToString("F2") + "KB";
            }
        }

        /// <summary>
        /// 加载数据
        /// </summary>
        private void LoadData()
        {
            linkFile = (LinkFile)Parameter[0];
        }

        /// <summary>
        /// 加载缓存数据
        /// </summary>
        private void LoadCacheData()
        {
            linkFile = (LinkFile)Caches[0];
        }

        private void bcOperate_OnButtonClick(object sender, int buttonIndex)
        {
            switch (buttonIndex)
            {
                case 0:
                    linkFile.Title = tbTitle.Text;
                    if (linkFileService.UpdateLinkFile(linkFile))
                        mssdlgexec.ShowDialog(this, "录音标题修改完成", DialogType.Confirm, FormManage.form_Deactivate);
                    break;
                case 1:
                    InputMethod.SHFullScreen(this.Handle, 4);
                    InputMethod.SipShowIM(1);
                    tbTitle.Focus();
                    break;
                case 2:
                    FormManage.GotoNext("FrmRcrdPlyBck", null, null, true);
                    break;
            }
        }
        


    }
}